﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;

namespace QuanLyKho
{
    class TienTe
    {
        private string kiHieu;
        private string loaiTien;
        private double tyGia;

        public TienTe() { }
        public TienTe(string _kiHieu, string _loaiTien, float _tyGia)
        {
            kiHieu = _kiHieu;
            loaiTien = _loaiTien;
            tyGia = _tyGia;
        }

        public string KiHieu
        {
            get
            {
                return kiHieu;
            }
            set
            {
                if (kiHieu == value)
                    return;
                kiHieu = value;
            }
        }
        public string LoaiTien
        {
            get
            {
                return loaiTien;
            }
            set
            {
                if (loaiTien == value)
                    return;
                loaiTien = value;
            }
        }
        public double TyGia
        {
            get
            {
                return tyGia;
            }
            set
            {
                if (tyGia == value)
                    return;
                tyGia = value;
            }
        }

        public static DataTable getList(TaiKhoan taiKhoan)
        {
            DataSet ds = connection.FillDataSet("proc_getDanhSachTienTe", CommandType.StoredProcedure, null, null, taiKhoan);
            return ds.Tables[0];
        }
        public void insert(TaiKhoan taiKhoan)
        {
            string[] para = { "@KyHieu", "@LoaiTien", "@TyGia" };
            string[] values = { kiHieu, loaiTien, tyGia + "" };
            connection.Excute("proc_insertTienTe", CommandType.StoredProcedure, para, values, taiKhoan);
        }
        public void update(TaiKhoan taiKhoan)
        {
            string[] para = { "@KyHieu", "@LoaiTien", "@TyGia" };
            string[] values = { kiHieu, loaiTien, tyGia + "" };
            connection.Excute("proc_updateTienTe", CommandType.StoredProcedure, para, values, taiKhoan);
        }
        public void delete(TaiKhoan taiKhoan)
        {
            string[] para = { "@KyHieu" };
            string[] values = { kiHieu };
            connection.Excute("proc_deleteTienTe", CommandType.StoredProcedure, para, values, taiKhoan);
        }
    }
}
